package com.chuxing.security.controller;

import com.chuxing.domain.DTO.SendCodeDTO;
import com.chuxing.domain.Result;
import com.chuxing.security.service.EmailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LiuQi
 * @create 2024-11-19-下午2:05
 */
@RestController()
@RequestMapping("/email")
@Tag(name = "邮件服务", description = "邮件服务相关接口")
@RequiredArgsConstructor
public class EmailController {
    private static final Logger log = LoggerFactory.getLogger(EmailController.class);
    private final EmailService emailService;
    /**
     * 发送验证码接口
     * @param sendCodeDTO 包含用户信息的DTO，用于发送验证码
     * @return 返回发送验证码的结果，如果成功则返回成功信息
     */
    @Operation(summary = "发送验证码",description = "发送验证码")
    @PostMapping("/sendCode")
    public Result<Object> sendCode(@RequestBody SendCodeDTO sendCodeDTO){
        log.info("{}发送验证码", sendCodeDTO.getEmail());
        emailService.sendCode(sendCodeDTO);
        return Result.success("发送成功");
    }
}
